package com.example.interesting.distributed.lock.realize.strategy;

import org.redisson.api.RLock;

/**
 * @author fyw
 * @version 1.0
 * @description: 分布式锁实际执行策略
 * 仅实现基于redisson的分布式锁
 * @date 2024/3/16 13:24
 */
public interface DistributedLockExecutorStrategy<T> {

    /**
     * 获取锁逻辑
     *
     * @param key            获取锁的key
     * @param acquireTimeout 获取锁获取超时时间
     * @param expireTime     锁过期时间
     *                       业务逻辑未执行完成的话redisson会自动续期
     * @return RLock 锁实例对象
     */
    RLock acquireLock(String key, long acquireTimeout, long expireTime);

    /**
     * 释放锁逻辑
     *
     * @param lockInstance 锁实例对象
     * @return true解锁成功 false解锁失败
     */
    boolean releaseLock(T lockInstance);
}
